/*
 * @Author: CC-TSR
 * @Date: 2021-01-08 08:57:20
 * @LastEditTime: 2021-12-16 19:41:31
 * @LastEditors: xiejiancheng1999@qq.com
 * @Description: 
 * @FilePath: \land-master\src\router\index.js
 * @可以输入预定的版权声明、个性签名、空行等
 */
import Vue from "vue";
import VueRouter from "vue-router";
import MainPage from "./mainPage";
import login from "./loginRouter.js";

Vue.use(VueRouter);

const routes = [MainPage];

routes.push(...login);

const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error);
};

const router = new VueRouter({
  mode:"history",
  routes
});
// router.beforeEach((to, from, next) => {
//   let token = sessionStorage.getItem("token");
//   if (token) {
//     if (to.name === "MainPage") {
//       next({ name: "yzt" });
//     } else if (to.name === "xtgl") {
//       next({ name: "yhgl" });
//     } else {
//       next();
//     }
//   } else {
//     if (to.name === "login") {
//       next();
//     } else {
//       next({ name: "login" });
//     }
//   }
// });

export default router;
